import 'package:flutter/material.dart';
import 'package:helloflutter/page/search.dart';
import 'package:helloflutter/page/tabs/home.dart';
import 'package:helloflutter/routes/routes.dart';

void main() {
  runApp(MyApp());
}

/// MaterialApp.routes
/// 和
/// onGenerateRoute
/// 不能混用
class MyApp extends StatelessWidget {



  MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      onGenerateRoute:defaultOnGenerateRoute,
      home: Scaffold(
          appBar: AppBar(
            title: const Text("Flutter Demo"),
          ),
          body: const TestBody()),
      // routes: routes,
    );
  }
}

class TestBody extends StatelessWidget {

  const TestBody({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: ListView(
        children: [
          const Text("Hello Flutter!"),
          ElevatedButton(
            onPressed: () {
              Navigator.pushNamed(context, "/search",arguments: {"test":"ABC TEST"});
            },
            child: const Text("search"),
          ),
          ElevatedButton(
            onPressed: () {
              Navigator.pushNamed(context, "/home");
            },
            child: const Text("home"),
          ),
        ],
      ),
    );
  }
}
